package com.doublefish.doublefishrobot.ui.home.s5;

import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.doublefish.doublefishrobot.R;
import com.doublefish.doublefishrobot.base.BaseActivity;
import com.doublefish.doublefishrobot.ui.home.adapter.S5ModeCourseAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 作者:dugaofeng on 2025/3/19 10:34
 */
public class S5ModeBgCourseActivity extends BaseActivity {


    private static final String HUAWEI = "huawei";   //华为
    private static final String XIAOMI = "xiaomi";   //小米
    private static final String VIVO = "vivo";   //vivo
    private static final String OPPO = "oppo";   //oppo

    @BindView(R.id.tv_title)
    TextView titleTv;

    @BindView(R.id.recyclerview)
    RecyclerView recyclerView;

    private S5ModeCourseAdapter adapter;


    @Override
    protected int getLayoutId() {
        return R.layout.activity_s5_course;
    }

    @Override
    protected void initView() {
        titleTv.setText(R.string.bg_course);

        adapter = new S5ModeCourseAdapter(this,null);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.setAdapter(adapter);
    }

    @Override
    protected void initData() {
        String manufacturer = android.os.Build.MANUFACTURER;
        String brand = android.os.Build.BRAND;

        //华为
//        D/DeviceInfo: Manufacturer: HUAWEI
//        D/DeviceInfo: Brand: HONOR
//        小米
//        D/DeviceInfo: Manufacturer: Xiaomi
//        D/DeviceInfo: Brand: Redmi

        List<S5ModeCourseAdapter.CourseInfoBean> list;
        if (HUAWEI.equalsIgnoreCase(manufacturer)) {
            list = createHuaweiBeans(manufacturer, brand);
        } else if (XIAOMI.equalsIgnoreCase(manufacturer)) {
            list = createXiaomiBeans(manufacturer, brand);
        } else if (OPPO.equalsIgnoreCase(manufacturer)) {
            list = createOppoBeans(manufacturer, brand);
        } else {
            //其他设备型号
            list = createOtherBeans(manufacturer, brand);
        }

        //测试数据
//        list = createHuaweiBeans(manufacturer, brand);
//        list = createXiaomiBeans(manufacturer, brand);
//        list = createOtherBeans(manufacturer, brand);

        adapter.setNewInstance(list);
    }

    @Override
    protected void initListener() {

    }

    @OnClick(R.id.ll_back)
    public void onBackClick() {
        finish();
    }

    private List<S5ModeCourseAdapter.CourseInfoBean> createHuaweiBeans(String manufacturer, String brand) {
        if (brand == null) {
            brand = "";
        }

        List<S5ModeCourseAdapter.CourseInfoBean> list = new ArrayList<>();

        S5ModeCourseAdapter.CourseInfoBean tipsBean = new S5ModeCourseAdapter.CourseInfoBean();
        tipsBean.setTipsText(getString(R.string.your_phone_is) + " " + manufacturer + (brand.isEmpty() ? "" : ("/" + brand)) + "\n\n" + getString(R.string.huawei_tips_0));
        list.add(tipsBean);

        S5ModeCourseAdapter.CourseInfoBean tipsBean1 = new S5ModeCourseAdapter.CourseInfoBean();
        tipsBean1.setTipsText(getString(R.string.huawei_tips_1));
        tipsBean1.setImageResource(R.mipmap.bg_huawei_1);
        list.add(tipsBean1);

        S5ModeCourseAdapter.CourseInfoBean tipsBean2 = new S5ModeCourseAdapter.CourseInfoBean();
        tipsBean2.setTipsText(getString(R.string.huawei_tips_2));
        tipsBean2.setImageResource(R.mipmap.bg_huawei_2);
        list.add(tipsBean2);

        S5ModeCourseAdapter.CourseInfoBean tipsBean3 = new S5ModeCourseAdapter.CourseInfoBean();
        tipsBean3.setTipsText(getString(R.string.huawei_tips_3));
        tipsBean3.setImageResource(R.mipmap.bg_huawei_3);
        list.add(tipsBean3);

        S5ModeCourseAdapter.CourseInfoBean tipsBean4 = new S5ModeCourseAdapter.CourseInfoBean();
        tipsBean4.setTipsText(getString(R.string.huawei_tips_4));
        tipsBean4.setImageResource(R.mipmap.bg_huawei_4);
        list.add(tipsBean4);

        S5ModeCourseAdapter.CourseInfoBean tipsBean5 = new S5ModeCourseAdapter.CourseInfoBean();
        tipsBean5.setTipsText(getString(R.string.huawei_tips_5));
        list.add(tipsBean5);

        return list;
    }

    private List<S5ModeCourseAdapter.CourseInfoBean> createXiaomiBeans(String manufacturer, String brand) {
        if (brand == null) {
            brand = "";
        }

        List<S5ModeCourseAdapter.CourseInfoBean> list = new ArrayList<>();

        S5ModeCourseAdapter.CourseInfoBean tipsBean = new S5ModeCourseAdapter.CourseInfoBean();
        tipsBean.setTipsText(getString(R.string.your_phone_is) + " " + manufacturer + (brand.isEmpty() ? "" : ("/" + brand)) + "\n\n" + getString(R.string.xiaomi_tips_0));
        list.add(tipsBean);

        S5ModeCourseAdapter.CourseInfoBean tipsBean1 = new S5ModeCourseAdapter.CourseInfoBean();
        tipsBean1.setTipsText(getString(R.string.xiaomi_tips_1));
        tipsBean1.setImageResource(R.mipmap.bg_xiaomi_1);
        list.add(tipsBean1);

        S5ModeCourseAdapter.CourseInfoBean tipsBean2 = new S5ModeCourseAdapter.CourseInfoBean();
        tipsBean2.setTipsText(getString(R.string.xiaomi_tips_2));
        tipsBean2.setImageResource(R.mipmap.bg_xiaomi_2);
        list.add(tipsBean2);

        S5ModeCourseAdapter.CourseInfoBean tipsBean3 = new S5ModeCourseAdapter.CourseInfoBean();
        tipsBean3.setTipsText(getString(R.string.xiaomi_tips_3));
        tipsBean3.setImageResource(R.mipmap.bg_xiaomi_3);
        list.add(tipsBean3);

        S5ModeCourseAdapter.CourseInfoBean tipsBean4 = new S5ModeCourseAdapter.CourseInfoBean();
        tipsBean4.setTipsText(getString(R.string.xiaomi_tips_4));
        tipsBean4.setImageResource(R.mipmap.bg_xiaomi_4);
        list.add(tipsBean4);

        S5ModeCourseAdapter.CourseInfoBean tipsBean5 = new S5ModeCourseAdapter.CourseInfoBean();
        tipsBean5.setTipsText(getString(R.string.xiaomi_tips_5));
        list.add(tipsBean5);
        return list;
    }

    private List<S5ModeCourseAdapter.CourseInfoBean> createOppoBeans(String manufacturer, String brand) {
        if (brand == null) {
            brand = "";
        }

        List<S5ModeCourseAdapter.CourseInfoBean> list = new ArrayList<>();

        S5ModeCourseAdapter.CourseInfoBean tipsBean = new S5ModeCourseAdapter.CourseInfoBean();
        tipsBean.setTipsText(getString(R.string.your_phone_is) + " " + manufacturer + (brand.isEmpty() ? "" : ("/" + brand)) + "\n\n" + getString(R.string.oppo_tips_0));
        list.add(tipsBean);

        S5ModeCourseAdapter.CourseInfoBean tipsBean1 = new S5ModeCourseAdapter.CourseInfoBean();
        tipsBean1.setTipsText(getString(R.string.oppo_tips_1));
        tipsBean1.setImageResource(R.mipmap.bg_oppo_1);
        list.add(tipsBean1);

        S5ModeCourseAdapter.CourseInfoBean tipsBean2 = new S5ModeCourseAdapter.CourseInfoBean();
        tipsBean2.setTipsText(getString(R.string.oppo_tips_2));
        tipsBean2.setImageResource(R.mipmap.bg_oppo_2);
        list.add(tipsBean2);

        S5ModeCourseAdapter.CourseInfoBean tipsBean3 = new S5ModeCourseAdapter.CourseInfoBean();
        tipsBean3.setTipsText(getString(R.string.oppo_tips_3));
        tipsBean3.setImageResource(R.mipmap.bg_oppo_3);
        list.add(tipsBean3);

        S5ModeCourseAdapter.CourseInfoBean tipsBean4 = new S5ModeCourseAdapter.CourseInfoBean();
        tipsBean4.setTipsText(getString(R.string.oppo_tips_4));
        tipsBean4.setImageResource(R.mipmap.bg_oppo_4);
        list.add(tipsBean4);

        S5ModeCourseAdapter.CourseInfoBean tipsBean5 = new S5ModeCourseAdapter.CourseInfoBean();
        tipsBean5.setTipsText(getString(R.string.oppo_tips_5));
        list.add(tipsBean5);
        return list;
    }

    private List<S5ModeCourseAdapter.CourseInfoBean> createOtherBeans(String manufacturer, String brand) {
        if (manufacturer == null) {
            manufacturer = getString(R.string.unknow_brand);
        }
        if (brand == null) {
            brand = "";
        }

        List<S5ModeCourseAdapter.CourseInfoBean> list = new ArrayList<>();

        S5ModeCourseAdapter.CourseInfoBean tipsBean = new S5ModeCourseAdapter.CourseInfoBean();
        tipsBean.setTipsText(getString(R.string.your_phone_is) + " " + manufacturer + (brand.isEmpty() ? "" : ("/" + brand)) + "\n\n" + getString(R.string.unknow_brand_tips));
        list.add(tipsBean);

        return list;
    }
}